﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Data;
using Business;
using Data;
using DataLibrery.Insert;
using Common;

namespace WebBanDT.AdminControl
{
    public partial class ThemSuaXoaSX : System.Web.UI.UserControl
    {
        LayNSX ds = new LayNSX();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                Load_data();
            }
        }
        protected void Load_data()
        {
            Repeater1.DataSource =ds.getDSNSX();
            Repeater1.DataBind();
        }

        protected void Thucthi(object sender, RepeaterCommandEventArgs e)
        {

            if (e.CommandName == "Sua")
            {
                ((Label)e.Item.FindControl("lblMaNSX")).Visible = false;
                ((Label)e.Item.FindControl("lblTenNSX")).Visible = false;

                ((TextBox)e.Item.FindControl("txtMaNSX")).Visible = true;
                ((TextBox)e.Item.FindControl("txtTenNSX")).Visible = true;

                ((LinkButton)e.Item.FindControl("LinkButton1")).Visible = false;
                ((LinkButton)e.Item.FindControl("lbtn1")).Visible = false;
                ((LinkButton)e.Item.FindControl("LinkButton2")).Visible = true;
                ((LinkButton)e.Item.FindControl("LinkButton3")).Visible = true;
            }
            if (e.CommandName == "Luu")
            {

               
            }
            if (e.CommandName == "Xoa")
            {

                try
                {
                    
                }
                catch (Exception)
                {
                    
                }
            }
            if (e.CommandName == "Khongluu")
            {
                ((Label)e.Item.FindControl("lblMaNSX")).Visible = true;
                ((Label)e.Item.FindControl("lblTenNSX")).Visible = true;

                ((TextBox)e.Item.FindControl("txtMaNSX")).Visible = false;
                ((TextBox)e.Item.FindControl("txtTenNSX")).Visible = false;

                ((LinkButton)e.Item.FindControl("LinkButton1")).Visible = true;
                ((LinkButton)e.Item.FindControl("lbtn1")).Visible = true;
                ((LinkButton)e.Item.FindControl("LinkButton2")).Visible = false;
                ((LinkButton)e.Item.FindControl("LinkButton3")).Visible = false;
            }
        }
        public void Xoatrang()
        {
            txtMaNSX.Text = string.Empty;
            txtTenNSX.Text = string.Empty;
        }
    }
}